<?php

namespace Siese\EntityBundle\Service;

use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Form\FormFactoryInterface;
use Doctrine\ORM\EntityManager;
use Siese\EntityBundle\Form\FiltrosBusquedaType;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Siese\EntityBundle\Entity\InspeccionesEntidadesPob;

class filtrosBusqueda {
    
    protected $container;
    protected $formFactory;
    protected $entityManager;
    protected $urlGenerator;
    
    public function __construct(EntityManager $entityManager,Container $container, FormFactoryInterface $formFactory,UrlGeneratorInterface $urlGenerator) {
      $this->container = $container;
      $this->formFactory = $formFactory;
      $this->entityManager = $entityManager;
      $this->urlGenerator = $urlGenerator;
    }
    
    public function generarFormularioFiltros($urlAction) {
        $entity = new InspeccionesEntidadesPob();
        
      $form = $this->formFactory->create(new FiltrosBusquedaType($this->entityManager),$entity, array(
        'action' => $this->urlGenerator->generate($urlAction),
        'method' => 'POST',
      ));
        
      $form->add('submit', 'submit', array('label' => 'Buscar Inspección',
                                           'attr' => array('class' => 'btn btn-warning')));        
      return $form;
   }  
}
